package com.mebs.edi.datalayer.jpa;

import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;

import com.mebs.edi.datalayer.CompanyDao;
import com.mebs.model.Company;

public class JpaCompanyDao extends JpaGenericDao implements CompanyDao {

	public Company getCompany(String companyName) {
		EntityManager em = getEntityManager();
		
		TypedQuery<Company> query = em
			.createQuery("from Company c where c.name = :companyName", Company.class)
			.setParameter("companyName", companyName);
		Company Company = query.getSingleResult();
		
		return Company;
	}
	
	public Company getById(Long id) {
		EntityManager em = getEntityManager();
		
		Company company = em.find(Company.class, id);
		return company;
	}
}
